package com.ngc.mall.controller;

import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.MemberLevelDomain;
import com.ngc.mall.service.IMemberLevelService;
import com.ngc.mall.vo.MemberLevelVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/member")
public class MemberController {

    @Autowired
    private IMemberLevelService iMemberLevelService;

    @GetMapping("/level")
    @ApiOperation("获取所有会员等级及其权益")
    public ResponseResult<List<MemberLevelDomain>> selectAll(){
        return ResponseResult.success(iMemberLevelService.list());
    }

    @GetMapping("/level/id/{id}")
    @ApiOperation("根据id获取会员等级详情")
    public ResponseResult<MemberLevelVO> getMemberLevelDetailById(@PathVariable Long id){
        return ResponseResult.success(iMemberLevelService.getDetailById(id));
    }
}
